package cn.yunhe.servlet;

import cn.yunhe.service.AdminService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class SearchUserByNameServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.setCharacterEncoding("UTF-8");
       response.setCharacterEncoding("UTF-8");
        String name= request.getParameter("name");
        AdminService adminService=new AdminService();
       boolean flag=  adminService.searchUserByName(name);
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out=response.getWriter();
        if(flag){
            out.print(true);
        }else {
            out.print(false);
        }
    }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
